package org.seckill.common;

/**
 * @author Elmer
 * @create 2017-07-30 15:20
 * @desc 常量
 **/
public class Const {
    public enum SeckillStatusEnum {
        KILL_SUCCESS(1,"秒杀成功"),
        KILL_END(0,"秒杀结束"),
        KILL_REPEAT(-1,"重复秒杀"),
        INNER_ERROR(-2,"系统异常"),
        DATA_REWRITE(-3,"数据篡改")
        ;

        SeckillStatusEnum(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        private int code;
        private String desc;

        public String getDesc() {
            return desc;
        }

        public int getCode() {
            return code;
        }

        public static SeckillStatusEnum statusOf(int index){
            for (SeckillStatusEnum status:values()) {
                if (status.getCode()==index){
                    return status;
                }
            }
            return null;
        }
    }
}
